gtkswitch: Decouple set_state with set_active.
authorAlessandro Bono <alessandro.bono369@gmail.com>
Mon, 23 Jan 2023 15:03:45 +0000 (16:03 +0100)
committerAlessandro Bono <alessandro.bono369@gmail.com>
Tue, 24 Jan 2023 13:55:16 +0000 (14:55 +0100)
Allow the user to set a state that doesn't reflect the active property.

gtk/gtkswitch.c

index e59f933617b495f0880e54cd7bdcb8315ae2c4db..062e7ea9606965a135a6360c57431d0824b0859c 100644 (file)
@@ -742,9 +742,8 @@ gtk_switch_get_active (GtkSwitch *self)
  *
  * Sets the underlying state of the `GtkSwitch`.
  *
- * Normally, this is the same as [property@Gtk.Switch:active], unless
- * the switch is set up for delayed state changes. This function is
- * typically called from a [signal@Gtk.Switch::state-set] signal handler.
+ * This function is typically called from a [signal@Gtk.Switch::state-set]
+ * signal handler in order to set up delayed state changes.
  *
  * See [signal@Gtk.Switch::state-set] for details.
  */
@@ -761,12 +760,6 @@ gtk_switch_set_state (GtkSwitch *self,
 
   self->state = state;
 
-  /* This will be a no-op if we're switching the state in response
-   * to a UI change. We're setting active anyway, to catch 'spontaneous'
-   * state changes.
-   */
-  gtk_switch_set_active (self, state);
-
   if (state)
     gtk_widget_set_state_flags (GTK_WIDGET (self), GTK_STATE_FLAG_CHECKED, FALSE);
   else